<template>
  <div class="OBSMaintain">
    <!-- 权限清单tabs-> 资源数据链接   permissionListVisible:-->
    <el-dialog title="资源数据"
               :visible.sync="dialogVisibleNum"
               width="80%"
               :close-on-click-modal="false"
               :before-close="handleCloseNum">
      <div>
        <el-table :header-cell-style="{background:'#f5f5f5'}"
                  :data="sourceData"
                  border
                  height="310"
                  style="width: 100%">
          <el-table-column prop="system_name"
                           label="所属系统"
                           align="center"
                           show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="object_sort_name"
                           label="类型"
                           align="center"
                           show-overflow-tooltip>

          </el-table-column>
          <el-table-column prop="object_name"
                           label="权限项名称"
                           align="center"
                           show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="object_no"
                           label="权限编号"
                           align="center"
                           show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="object_module"
                           label="module"
                           align="center"
                           show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="object_method"
                           label="method"
                           align="center"
                           show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="object_para"
                           label="参数"
                           align="center"
                           show-overflow-tooltip>
          </el-table-column>
          <el-table-column label="是否菜单项"
                           align="center"
                           show-overflow-tooltip>
            <template slot-scope="scope">
              <span>{{scope.row.is_menu==0?'否':'是'}}</span>
            </template>
          </el-table-column>
          <el-table-column label="是否授权项"
                           align="center"
                           show-overflow-tooltip>
            <template slot-scope="scope">
              <span>{{scope.row.is_priv==0?'否':'是'}}</span>
            </template>
          </el-table-column>

          <el-table-column label="是否流程项"
                           align="center"
                           show-overflow-tooltip>
            <template slot-scope="scope">
              <span>{{scope.row.is_flow==0?'否':'是'}}</span>
            </template>
          </el-table-column>
          <el-table-column label="是否普通项"
                           align="center"
                           show-overflow-tooltip>
            <template slot-scope="scope">
              <span>{{scope.row.is_samp==0?'否':'是'}}</span>
            </template>
          </el-table-column>
        </el-table>
        <div style="margin-top:20px!important;">
          <el-pagination @current-change="handleChangeSource"
                         :current-page="requestParamSource.page"
                         :page-sizes="[10]"
                         layout="total,sizes,prev, pager, next, jumper"
                         background
                         align="center"
                         id="pagination"
                         :total="requestParamSource.total_count">
          </el-pagination>
        </div>
      </div>
    </el-dialog>
    <el-row class="row_maintain">
      <el-col :span="24">
        <el-col :span="6"
                class="left-content">
          <div class="select-company">
            <el-select v-model="selectedCompany"
                       value-key="company_id"
                       @change="chooseCompany">
              <el-option v-for="(item) in selectedCompanyList"
                         :key="item.company_id"
                         :label="item.company_name"
                         :value="item">
              </el-option>
            </el-select>
            <div class="head-left-btn">
              <el-button type="primary"
                         size="mini"
                         @click="showCompanyListDialog"
                         class="head-left-selectunit"
                         id="headLeftSelect">
                选择
              </el-button>
              <el-button type="primary"
                         size="mini"
                         @click="goPostTemplate"
                         class="head-left-selectunit"
                         id="headLeftSelect">

                岗位模板
              </el-button>
            </div>

          </div>
          <div class="tree-container">
            <OrgainzationTree :selectedNode.sync="currentNode"
                              :assignedNode.sync="assignNode"
                              :assignedTemplateNode.sync="assignTemplateNode"
                              :assignedPermissionNode.sync="assignPermissionNode"
                              :rightMenu="true"
                              :companyId="orgainzationTreeParam.company_id"></OrgainzationTree>
          </div>

        </el-col>
        <el-col :span="18"
                class="col_tabs">
          <el-tabs type="border-card"
                   class="unit_tabs">
            <el-tab-pane label="权限模版">
              <el-col class="table-content"
                      :span="24">
                <el-table ref="clearTableTemp"
                          :highlight-current-row="true"
                          @current-change="handleClearChangeTemp"
                          :header-cell-style="{background:'#f5f5f5'}"
                          :data="jobPermissionTempList.list"
                          border
                          class="obs-style">
                  <el-table-column prop="auth_template_name"
                                   label="模板名称"
                                   align="center"
                                   show-overflow-tooltip>
                  </el-table-column>
                  <el-table-column label="资源数量"
                                   align="center"
                                   show-overflow-tooltip>
                    <template slot-scope="scope">
                      <el-button type="text"
                                 size="small"
                                 style="text-decoration:underline"
                                 @click="onNum(scope.row)">{{scope.row.object_num}}</el-button>
                    </template>
                  </el-table-column>

                  <el-table-column label="操作"
                                   align="center">
                    <template slot-scope="scope">
                      <el-button width="80px"
                                 size="mini"
                                 @click="jobPerDeleteConfirmTemp(scope)"
                                 type="text">
                        删除
                      </el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
              <el-col :span="24"
                      align="center"
                      style="margin-bottom:20px;">
                <el-pagination background
                               id="obs_page"
                               @size-change="handleSizeChangeTemp"
                               @current-change="handleCurrentChangeTemp"
                               :current-page="jobPermissionTempListParam.page"
                               :page-size="jobPermissionTempListParam.page_size"
                               :page-sizes="[10]"
                               layout="total,sizes,prev, pager, next, jumper"
                               :total="jobPermissionTempList.total_count">
                </el-pagination>
              </el-col>
            </el-tab-pane>
            <el-tab-pane label="权限清单">
              <!-- <el-tabs type="card"
                       class="Permiss">                

              </el-tabs> -->
              <el-row class="table-container"
                      style="margin-bottom:15px;">
                <el-col class="table-content"
                        :span="24">
                  <el-table ref="clearTable"
                            :highlight-current-row="true"
                            @current-change="handleClearChange"
                            :header-cell-style="{background:'#f5f5f5'}"
                            :data="jobPermissionList.list"
                            border
                            class="obs-style">
                    <el-table-column type="index"
                                     label="序号"
                                     sortable
                                     align="center"
                                     width="100"
                                     show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column prop="system_name"
                                     label="所属应用"
                                     align="center"
                                     show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column label="权限名称"
                                     prop="object_name"
                                     align="center"
                                     show-overflow-tooltip>
                    </el-table-column>

                    <el-table-column label="操作"
                                     align="center">
                      <template slot-scope="scope">
                        <el-button width="80px"
                                   size="mini"
                                   v-if="scope.row.job_object_rela_id !== null"
                                   @click="jobPerDeleteConfirm(scope)"
                                   type="text">
                          删除
                        </el-button>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-col>
                <el-col :span="24"
                        align="center"
                        style="margin-bottom:20px;">
                  <el-pagination background
                                 id="obs_page"
                                 @size-change="handleSizeChange"
                                 @current-change="handleCurrentChange"
                                 :current-page="jobPermissionListParam.page"
                                 :page-size="jobPermissionListParam.page_size"
                                 :page-sizes="[10]"
                                 layout="total,sizes,prev, pager, next, jumper"
                                 :total="jobPermissionList.total_count">
                  </el-pagination>
                </el-col>
              </el-row>
            </el-tab-pane>
            <!-- 轻应用权限 -->
            <el-tab-pane label="轻应用权限">
              <el-form ref="form"
                       :model="form"
                       label-width="100px">
                <el-row style="margin-bottom:15px"
                        class="table-container11">
                  <el-col :span="24">
                    <el-table ref="obsTable"
                              @current-change="handleObsChange"
                              :highlight-current-row="true"
                              :header-cell-style="{background:'#f5f5f5'}"
                              :data="applimit.list"
                              border
                              height="280"
                              class="obs-style">
                      <el-table-column prop="app_name"
                                       label="轻应用名称"
                                       align="center"
                                       show-overflow-tooltip>
                      </el-table-column>
                      <el-table-column label="操作"
                                       align="center">
                        <template slot-scope="scope">
                          <el-button width="80px"
                                     size="mini"
                                     @click="appLimitDeleteConfirm(scope.row)"
                                     type="text">
                            移除
                          </el-button>
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                          align="center"
                          style="margin-bottom:20px;">
                    <el-pagination background
                                   id="obs_page"
                                   @size-change="handleAppSizeChange"
                                   @current-change="handleAppCurrentChange"
                                   :current-page="getAppLimitParam.page"
                                   :page-sizes="[10]"
                                   layout="total,sizes,prev, pager, next, jumper"
                                   :page-size="getAppLimitParam.page_size"
                                   :total="applimit.total_count">
                    </el-pagination>
                  </el-col>
                </el-row>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="人员列表">
              <el-form ref="form"
                       :model="form"
                       label-width="100px">
                <el-row style="margin-bottom:20px;margin-top:20px;">
                  <el-col :span="12"
                          :offset="12"
                          class="person-style">
                    <el-col :span="24"
                            style="margin-left:1px;overflow:hidden;">
                      <el-col :span="19"
                              style="padding-right:27px;">
                        <el-input v-model="form.name"
                                  placeholder="请输入昵称">
                        </el-input>
                      </el-col>
                      <el-col :span="5">
                        <el-button type="primary"
                                   icon="el-icon-search"
                                   align="right"
                                   class="normal_btn"
                                   @click="onSearch">搜索</el-button>
                      </el-col>
                    </el-col>
                  </el-col>
                </el-row>
                <el-row style="margin-bottom:15px"
                        class="table-container11">
                  <el-col :span="24">
                    <el-table ref="obsTable"
                              @current-change="handleObsChange"
                              :highlight-current-row="true"
                              :header-cell-style="{background:'#f5f5f5'}"
                              :data="jobUserList.list"
                              border
                              height="280"
                              class="obs-style">
                      <el-table-column prop="user_no"
                                       label="系统账号"
                                       align="center"
                                       show-overflow-tooltip>
                      </el-table-column>
                      <el-table-column prop="user_name"
                                       label="用户姓名"
                                       align="center"
                                       show-overflow-tooltip>
                      </el-table-column>
                      <el-table-column prop="status_name"
                                       label="状态"
                                       align="center"
                                       show-overflow-tooltip>
                      </el-table-column>
                      <el-table-column prop="phone"
                                       label="手机号"
                                       align="center"
                                       show-overflow-tooltip>
                      </el-table-column>
                      <el-table-column prop="create_date"
                                       label="加入时间"
                                       align="center">
                      </el-table-column>
                      <el-table-column label="操作"
                                       align="center">
                        <template slot-scope="scope">
                          <el-button width="80px"
                                     size="mini"
                                     @click="jobUserDeleteConfirm(scope)"
                                     type="text">
                            删除
                          </el-button>
                          <el-button size="mini"
                                     v-if="getJobUserListParams.node_type === '2' || getJobUserListParams.node_type === '3'"
                                     @click="isAdmin(scope.row)"
                                     type="text">
                            设置管理员
                          </el-button>
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24"
                          align="center"
                          style="margin-bottom:20px;">
                    <el-pagination background
                                   id="obs_page"
                                   @size-change="handlePeopleSizeChange"
                                   @current-change="handleJobUserCurrentChange"
                                   :current-page="getJobUserListParam.page"
                                   :page-sizes="[10]"
                                   layout="total,sizes,prev, pager, next, jumper"
                                   :page-size="getJobUserListParam.page_size"
                                   :total="jobUserList.total_count">
                    </el-pagination>
                  </el-col>
                </el-row>
              </el-form>
            </el-tab-pane>
          </el-tabs>
        </el-col>
      </el-col>
    </el-row>
    <!-- 分配人员弹框 -->
    <el-dialog title="分配人员"
               :close-on-click-modal="false"
               :visible.sync="assignUserListVisible">
      <el-form :model="getAssignUserListParam"
               label-width="50px">
        <el-row>
          <el-col :span="7">
            <el-form-item label="账号"
                          prop="user_no">
              <el-input v-model="getAssignUserListParam.user_no"
                        placeholder="请输入账号"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="姓名"
                          prop="user_name">
              <el-input v-model="getAssignUserListParam.user_name"
                        placeholder="请输入姓名"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="手机"
                          prop="phone">
              <el-input v-model="getAssignUserListParam.phone"
                        placeholder="请输入手机"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-button class="search-btn"
                       @click="getAssignUserList"
                       type="primary"
                       id="headLeftSelect">搜索</el-button>
          </el-col>
        </el-row>

      </el-form>
      <el-table :data="assignUserList.list"
                row-key="user_id"
                height="310"
                :header-cell-style="{background:'#f5f5f5'}"
                @selection-change="selectUser"
                border>
        <el-table-column type="selection"
                         width="50">
        </el-table-column>
        <el-table-column prop="user_no"
                         label="系统账号">
        </el-table-column>
        <el-table-column prop="user_name"
                         label="用户姓名">
        </el-table-column>
        <el-table-column prop="status_name"
                         label="状态">
        </el-table-column>
        <el-table-column prop="phone"
                         label="手机号">
        </el-table-column>
        <el-table-column prop="create_date"
                         label="创建日期">
        </el-table-column>
      </el-table>
      <el-pagination background
                     id="obs_page"
                     @size-change="handleAssignUserSizeChange"
                     @current-change="handleAssignUserCurrentChange"
                     :current-page="getAssignUserListParam.page"
                     :page-sizes="[10]"
                     layout="total,sizes,prev, pager, next, jumper"
                     :page-size="getAssignUserListParam.page_size"
                     :total="assignUserList.total_count">
      </el-pagination>
      <div style="text-align:center;margin-top:20px;">
        <el-button @click="assignUserListVisible=false"
                   id="headLeftSelect"
                   style="color:white;">取消</el-button>
        <el-button type="primary"
                   @click="batchAssignUser"
                   id="headLeftSelect">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="设置管理员"
               :visible.sync="adminDialogVisible"
               width="30%">
      <span>是否设置为管理员</span>
      <span slot="footer"
            class="dialog-footer">
        <el-button @click="adminDialogVisible = false">取 消</el-button>
        <el-button type="primary"
                   @click="saveAdmin">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 分配权限弹框 -->
    <el-dialog title="分配权限"
               width="60%"
               :close-on-click-modal="false"
               :visible.sync="assignPermissionVisible">
      <AssignTempalte :isVisible="assignPermissionVisible"
                      :curPermissionIds.sync="assignPermissionIds"></AssignTempalte>
      <div style="text-align:center;margin-top:20px;">
        <el-button @click="assignPermissionVisible=false"
                   id="headLeftSelect"
                   style="color:white;">取消</el-button>
        <el-button type="primary"
                   @click="assignPermission"
                   id="headLeftSelect">确定</el-button>
      </div>
    </el-dialog>
    <!-- 分配权限模板弹框 -->
    <el-dialog title="分配模板"
               width="60%"
               :close-on-click-modal="false"
               :visible.sync="assignTemplateListVisible">

      <el-form :model="getAssignTemplateListParam"
               label-width="100px">
        <el-row>
          <el-col :span="10"
                  :offset="11">
            <el-form-item label="模板名称"
                          prop="auth_template_name"
                          style="margin-right:10px;">
              <el-input v-model="getAssignTemplateListParam.auth_template_name"
                        placeholder="请输入模板名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3"
                  style="text-align:right;">
            <el-button class="search-btn"
                       @click="getAssignTemplate"
                       type="primary"
                       id="headLeftSelect">搜索</el-button>
          </el-col>
        </el-row>
      </el-form>
      <el-table :data="assignTemplateList.list"
                row-key="auth_template_id"
                height="310px"
                :header-cell-style="{background:'#f5f5f5'}"
                @selection-change="selectTemplate"
                border>
        <el-table-column type="selection"
                         width="50">
        </el-table-column>
        <el-table-column prop="auth_template_name"
                         label="模板名称"
                         align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="权限查看"
                         align="center"
                         show-overflow-tooltip>
          <template slot-scope="scope">
            <el-button width="80px"
                       size="mini"
                       @click="getPermissionList(scope)"
                       type="text">
              查看
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination background
                     id="obs_page"
                     @size-change="handleTemplateSizeChange"
                     @current-change="handleTemplateCurrentChange"
                     :current-page="getAssignTemplateListParam.page"
                     :page-sizes="[10]"
                     layout="total,sizes,prev, pager, next, jumper"
                     :page-size="getAssignTemplateListParam.page_size"
                     :total="assignTemplateList.total_count">
      </el-pagination>
      <div style="text-align:center;margin-top:20px;">
        <el-button @click="assignTemplateListVisible=false"
                   id="headLeftSelect"
                   style="color:white;">取消</el-button>
        <el-button type="primary"
                   @click="saveAssignTemplate"
                   id="headLeftSelect">确定</el-button>
      </div>

    </el-dialog>
    <!-- 权限列表弹框 -->
    <el-dialog title="权限列表"
               :close-on-click-modal="false"
               width="70%"
               :visible.sync="permissionListVisible">
      <el-table :data="permissionList.list"
                row-key="object_no"
                height="310"
                :header-cell-style="{background:'#f5f5f5'}"
                border>
        <el-table-column prop="object_sort_name"
                         label="类型"
                         align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column align="center"
                         prop="object_name"
                         width="120px"
                         label="权限项名称"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="object_no"
                         label="权限编号"
                         align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="object_module"
                         label="module"
                         align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="object_method"
                         label="method"
                         align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="object_para"
                         label="参数"
                         align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="is_menu"
                         label="菜单项"
                         align="center"
                         show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag :type="scope.row.is_menu==1?'success':'danger'">
              {{scope.row.is_menu==1?'是':'否'}}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_priv"
                         label="授权项"
                         align="center"
                         show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag :type="scope.row.is_priv==1?'success':'danger'">
              {{scope.row.is_priv==1?'是':'否'}}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_flow"
                         label="流程项"
                         align="center"
                         show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag :type="scope.row.is_flow==1?'success':'danger'">
              {{scope.row.is_flow==1?'是':'否'}}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_samp"
                         label="普通项"
                         align="center"
                         show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag :type="scope.row.is_samp==1?'success':'danger'">
              {{scope.row.is_samp==1?'是':'否'}}
            </el-tag>
          </template>
        </el-table-column>

      </el-table>
      <div slot="footer"
           class="dialog-footer">
        <el-button id="headLeftSelect"
                   style="color:white;"
                   @click="permissionListVisible=false">取消</el-button>

      </div>
    </el-dialog>
    <!-- 公司列表弹框 -->
    <el-dialog :visible.sync="companyListVisible"
               :close-on-click-modal="false"
               :before-close="handleClose">
      <!-- title="选择公司" -->
      <el-form :model="getCompanyListParam"
               label-width="60px">
        <el-row class="show-dialog-style">
          <el-col :span="5">
            &nbsp;
          </el-col>
          <el-col :span="8"
                  style="padding-right:27px;">
            <el-select v-model="getCompanyListParam.company_type"
                       @change="onCompanyList">
              <el-option v-for="item in companyTypeList"
                         :key="item.code_id"
                         :label="item.name"
                         :value="item.value">
              </el-option>
            </el-select>
          </el-col>
          <el-col :span="8"
                  style="padding-right:27px!important;">
            <el-input v-model="getCompanyListParam.company_name"
                      placeholder="请输入公司名称">
            </el-input>
          </el-col>
          <el-col :span="3">
            <el-button @click="searchCompanyList"
                       type="primary"
                       id="headLeftSelect">搜索</el-button>
          </el-col>
        </el-row>
      </el-form>
      <el-table :data="companyList.list"
                @row-click="selectCompany"
                height="310"
                class="show-table-style"
                :header-cell-style="{background:'#f5f5f5'}"
                :highlight-current-row="true">
        <!-- <el-table-column prop="company_type_name"
                         label="单位类型">
        </el-table-column> -->
        <el-table-column prop="company_name"
                         label="单位名称"
                         align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="addr"
                         label="单位地址"
                         align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="contact_name"
                         label="负责人"
                         align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="contact_phone"
                         label="联系电话"
                         align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="create_date"
                         label="入驻时间"
                         align="center"
                         show-overflow-tooltip>
        </el-table-column>
      </el-table>
      <el-pagination id="pagination"
                     @current-change="handleCompanyCurrentChange"
                     :current-page="getCompanyListParam.page"
                     :page-sizes="[10]"
                     :page-size="getCompanyListParam.page_size"
                     background
                     layout="total,sizes,prev, pager, next, jumper"
                     :total="companyList.total_count"
                     style="text-align:center;margin-top:20px;margin-bottom:-20px;">
      </el-pagination>
      <div slot="footer"
           class="dialog-footer"
           style="text-align:center;">
        <el-button @click="companyListVisible=false,
          getCompanyListParam.company_type = '',
          getCompanyListParam.company_name = '',
          getCompanyListParam.page=1,
          orgainzationTreeParam.company_id = undefined ,
          orgainzationTreeParam.company_name = undefined"
                   id="back-style">取消</el-button>
        <el-button type="primary"
                   @click="confirmChooseCompany"
                   style="margin-left:16px;"
                   id="headLeftSelect">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { OBSManageApi } from '@/services/orgainzeManage';
import OrgainzationTree from '@/components/OrgainzationTree/OrgainzationTree';
import AssignTempalte from '@/components/PermissionTree/AssignTemplateList';
export default {
  components: {
    OrgainzationTree,
    AssignTempalte
  },
  data () {
    return {
      adminDialogVisible: false,
      permissionId: '', //分配权限id
      assignPermissionIds: [], // 选中的权限编号
      // permissionNo: {},
      currentRow: null,
      currentRowNextTemp: null,
      currentRowNext: null,
      requestParamSource: {
        page: 1,
        total_count: 0
      },
      total_count: 0,
      sourceData: [],
      dialogVisibleNum: false,
      form: {
        name: ''
      },
      unit: '',
      unitArr: [

      ],
      currentPage: 1,
      total: 20,
      pagesize: 10,
      orgainzationTreeParam: {
      },
      //轻应用权限列表
      applimit: {
        list: [],
        total_count: 0,
        total_page: 0
      },
      //轻应用权限请求参数
      getAppLimitParam: {
        job_id: '',
        is_page: 1,
        page: 1,
        page_size: 10
      },
      companyName: '',
      // 组织管理树数据
      orgainzationTreeData: [],
      // 获取岗位权限清单列表参数
      jobPermissionTempListParam: {
        job_id: '',
        is_page: 1,
        page: 1,
        page_size: 10
      },
      // 获取岗位权限清单列表参数
      jobPermissionListParam: {
        job_id: '',
        is_page: 1,
        page: 1,
        page_size: 10
      },
      // 岗位权限模版列表
      jobPermissionTempList: {
        list: [],
        total_count: 0,
        total_page: 0
      },
      // 岗位权限清单列表
      jobPermissionList: {
        list: [],
        total_count: 0,
        total_page: 0
      },
      // 当前选择节点
      currentNode: {},
      // 获取人员列表请求参数
      getJobUserListParam: {
        user_name: '',
        is_page: 1,
        page: 1,
        page_size: 10
      },
      getJobUserListParams: {

      },
      // 人员列表
      jobUserList: {
        list: [],
        total_count: 0,
        total_page: 0
      },
      // 请求分配人员列表参数
      getAssignUserListParam: {
        comp_id: '',
        job_id: '',
        user_no: '',
        user_name: '',
        phone: '',
        is_page: 1,
        page: 1,
        page_size: 10,
        show_all: 1,//显示全部
      },
      // 分配人员列表
      assignUserList: {
        list: []
      },
      // 分配人员弹框是否可见
      assignUserListVisible: false,
      // 右键分配人员时选中的节点
      assignNode: {},
      // 已选择分配人员的列表
      selectedAssignUser: [],
      // 请求分配模板列表参数
      getAssignTemplateListParam: {
        job_id: '',
        auth_template_name: '',
        is_page: 1,
        page: 1,
        page_size: 10
      },
      // 分配权限模板列表
      assignTemplateList: {
        list: []
      },
      // 分配权限模板是否可见
      assignTemplateListVisible: false,
      // 已选择分配模板的列表
      selectedAssignTemplate: [],
      // 右键分配模板时选中的节点
      assignTemplateNode: {},
      // 右键分配权限时选中的节点
      assignPermissionNode: {},
      // 分配权限弹框是否可见
      assignPermissionVisible: false,
      // 请求模板的权限列表的参数
      getPermissionListParam: {
        auth_template_id: '',
        is_page: 1,
        page: 1,
        page_size: 10
      },

      // 权限列表弹框是否可见
      permissionListVisible: false,
      // 对应模板的权限列表
      permissionList: {
        list: []
      },
      // 获取单位列表参数
      getCompanyListParam: {
        company_type: '',
        company_name: '',
        is_page: 1,
        page: 1,
        page_size: 10
      },
      // 选择单位弹框是否可见
      companyListVisible: false,
      // 单位列表
      companyList: {
        list: []
      },
      // 单位类型列表
      companyTypeList: [{ name: '全部', value: '' }],
      // 已选择的公司列表
      selectedCompanyList: [],
      // 当前选中的公司
      selectedCompany: {
        company_id: '',
        company_name: ''
      },
      requestParam: {
        object_no: ''
      },
      userId: '',
    }
  },
  created () {
    // let store = this.$store.state.userInfo
    // this.getJobUserListParam.user_name = store.user_name
    // this.getOrgainzationTree()
    this.getCompanyTypeList()
    this.$store.dispatch('setOrgainzationTree', [])
    this.getAssignTemplateListParam.system_no = this.$store.state.userInfo.system_no

    //获取存储的单位信息
    let unit = JSON.parse(window.sessionStorage.getItem('unitData'))
    let unitDefault = JSON.parse(window.sessionStorage.getItem('unitDefaultData'))
    if (this.selectedCompany.company_name === '' && unit) {
      this.selectedCompanyList = unit
      if (unitDefault) {
        this.selectedCompany.company_id = unitDefault.company_id
        this.orgainzationTreeParam.company_id = unitDefault.company_id
        this.orgainzationTreeParam.company_name = unitDefault.company_name
        this.getOrgainzationTree()
      }
    }
  },
  mounted () {
    //监听页面刷新
    window.addEventListener('beforeunload', e => this.beforeunloadHandler(e))
  },
  destroyed () {
    window.removeEventListener('beforeunload', e => this.beforeunloadHandler(e))
  },
  watch: {
    currentNode: {
      handler (newval, oldval) {
        console.log(newval.node_type);
        let params = {}
        this.getJobUserListParam.node_type = newval.node_type

        if (newval.node_type === '3') {
          // console.log('csy_console=', '3');
          this.getJobUserListParams.user_name = ''// 人员列表清空记忆值
          this.form.name = ''// 人员列表清空记忆值
          this.getJobUserListParams = {}
          this.jobPermissionTempListParam.job_id = newval.id
          this.jobPermissionListParam.job_id = newval.id
          console.log(this.jobPermissionListParam.job_id);
          this.getAppLimitParam.job_id = newval.id
          params.job_id = newval.id
          this.getJobUserListParams = Object.assign(params, this.getJobUserListParam)
          this.getJobPermissionTempList();//权限模板
          this.getJobPermissionList()// 清单列表数据
          this.getJobUserList()// 人员列表数据
          this.getLightappList() //轻应用列表 岗位显示
        } else if (newval.node_type === '2') {
          // console.log('csy_console=', '2')
          this.getJobUserListParams.user_name = ''// 人员列表清空记忆值
          this.form.name = ''// 人员列表清空记忆值
          this.jobPermissionList = {}
          this.getJobUserListParams = {}
          this.applimit = {}  //部门,轻应用权限列表清空
          params.company_id = newval.company_id
          params.dept_no = newval.org_no
          params.job_id = newval.id  //为部门时获取id  设置管理员
          this.getJobUserListParams = Object.assign(params, this.getJobUserListParam)
          this.getJobUserList()// 人员列表数据
        } else if (newval.node_type === '1') {
          // console.log('csy_console=', '1')
          this.getJobUserListParams.user_name = ''// 人员列表清空记忆值
          this.form.name = ''// 人员列表清空记忆值
          this.jobPermissionList = {}
          this.getJobUserListParams = {}
          this.applimit = {}  //单位,轻应用权限列表清空
          params.company_id = newval.company_id
          params.org_no = newval.no
          this.getJobUserListParams = Object.assign(params, this.getJobUserListParam)
          this.getJobUserList()// 人员列表数据
        }
      },
      deep: true
    },
    assignNode: {
      handler (newval, oldval) {
        console.log(newval);
        if (newval.id) {
          this.getAssignUserListParam.job_id = newval.id
          this.assignUserListVisible = true
          this.getAssignUserList()
        }
      },
      deep: true
    },
    //分配权限模板
    assignTemplateNode: {
      handler (newval, oldval) {
        if (newval.id) {
          this.getAssignTemplateListParam.job_id = newval.id
          this.getAssignTemplateListParam.org_no = newval.org_no
          this.assignTemplateListVisible = true
          this.getAssignTemplate()
        }
      },
      deep: true
    },
    //分配权限
    assignPermissionNode: {
      handler (newval) {
        console.log(newval);
        this.permissionId = newval.id
        this.assignPermissionVisible = true
      },
      deep: true
    },
    // permissionNo: {
    //   handler (newval, oldval) {
    //     this.requestParam.object_no = newval.object_no
    //   },
    //   deep: true
    // }
  },
  methods: { 
    // 权限清单 ->默认给表格第一行添加选中背景色
    setCurrentNextTemp (row) {
      this.$refs.clearTableTemp.setCurrentRow(row)
    },
    // 获取岗位权限模板列表数据
    getJobPermissionTempList () {
      OBSManageApi.getJobPermissionList({
        params: this.jobPermissionTempListParam
      }).then(res => {
        // console.log(res, 'get jpb permission list')
        if (res.code === 0) {
          this.jobPermissionTempList = res.data
          if (this.jobPermissionTempList.list.length != 0 || this.jobPermissionTempList.list == undefined) {
            this.setCurrentNextTemp(this.jobPermissionTempList[0])
          } else {

          }
        }
      })
    },
    //页面刷新
    beforeunloadHandler (e) {
      e = e || window.event
      if (e) {
        window.sessionStorage.removeItem('unitData')
        window.sessionStorage.removeItem('unitDefaultData')
      }
    },
    isAdmin (row) {
      this.adminDialogVisible = true
      this.userId = row.user_id
    },
    saveAdmin () {
      OBSManageApi.setAdmin({
        data: {
          node_type: this.getJobUserListParam.node_type, //节点类型
          id: this.jobPermissionListParam.job_id,  //节点id
          user_id: this.userId,  //用户id 
        }
      }).then(res => {
        if (res.code === 0) {
          this.$message.success('设置成功')
          this.adminDialogVisible = false
        }
      })
    },
    // 为当前行的模板分配权限---确定按钮被触发的事件
    assignPermission (scope) {
      let ids = ''
      if (this.assignPermissionIds.length > 0) {
        // this.assignPermissionIds.map((item) => {
        //   ids.push(item.object_id)
        // })
        ids = this.assignPermissionIds.join(',')
        OBSManageApi.saveAssignPermission({
          data: {
            job_id: this.permissionId,
            object_ids: ids
          }
        }).then(res => {
          if (res.msg == 'SUCCESS') {
            this.assignPermissionVisible = false
            this.$message.success('添加成功！')
            this.getJobPermissionTempList();//权限模板
            this.getJobPermissionList()
            // this.todosFreshAuth = this.todosFreshAuth + 1
            // this.getPowerMgtList();
          }
        }, err => {
          console.log(err)
        })
      } else {
        this.$message('请先勾选需要分配的权限!')
      }
    },
    //轻应用权限-每页条数
    handleAppSizeChange (page) {
      this.getAppLimitParam.page_size = page
      this.getLightappList()
    },
    //轻应用权限-页码
    handleAppCurrentChange (page) {
      this.getAppLimitParam.page = page
      this.getLightappList()
    },
    //进入岗位模板管理页面
    goPostTemplate () {
      this.$router.push({ path: '/PostTemplate' })
    },
    // 分配人员列表-分页
    handleAssignUserSizeChange (size) {
      this.getAssignUserListParam.page_size = size
      this.getAssignUserListParam.page = 1
      this.getAssignUserList()
    },
    handleAssignUserCurrentChange (page) {
      this.getAssignUserListParam.page = page
      this.getAssignUserList()
    },
    // // 权限模板列表-分页
    handleTemplateSizeChange (size) {
      this.getAssignTemplateListParam.page_size = size
      this.getAssignTemplateListParam.page = 1
      this.getAssignTemplate()
    },
    handleTemplateCurrentChange (page) {
      this.getAssignTemplateListParam.page = page
      this.getAssignTemplate()
    },
    // 人员列表 ->tabs背景色
    handleObsChange (val) {
      this.currentRow = val
    },
    setCurrent (row) {
      this.$refs.obsTable.setCurrentRow(row)
    },
    // 权限清单 ->值改变添加背景色
    handleClearChangeTemp (val) {
      this.currentRowNextTemp = val
    },
    // 权限清单 ->值改变添加背景色
    handleClearChange (val) {
      this.currentRowNext = val
    },
    // 权限清单 ->默认给表格第一行添加选中背景色
    setCurrentNext (row) {
      this.$refs.clearTable.setCurrentRow(row)
    },
    // 资源数据清空数据
    handleCloseNum (done) {
      this.dialogVisibleNum = false
      this.requestParamSource.page = 1
    },
    // 权限清单tabs-资源数据分页
    handleChangeSource (page) {
      this.getPermissionListParam.page = page
      OBSManageApi.getTemplatePermissionList({
        params: this.getPermissionListParam
      }).then(res => {
        // console.log(res, 'get template permission list')
        if (res.code === 0) {
          // this.jobPermissionList.list = res.data.list;
          this.sourceData = res.data.list
          this.getPermissionListParam.total_count = res.data.total_count
        }
      })
    },
    // 资源数据
    onNum (row) {
      this.dialogVisibleNum = true
      // row.auth_template_id
      this.getPermissionListParam.auth_template_id = row.auth_template_id
      OBSManageApi.getTemplatePermissionList({
        params: this.getPermissionListParam
      }).then(res => {
        // console.log(res, 'get template permission list')
        if (res.code === 0) {
          // this.jobPermissionList.list = res.data.list;
          this.sourceData = res.data.list
          this.requestParamSource.total_count = res.data.total_count
        }
      })
      // console.log('资源数据=', row)
    },
    // 人员列表tabs-搜索功能
    onSearch () {
      this.getJobUserListParams.user_name = this.form.name
      this.getJobUserList()
    },
    // 选择单位右上角关闭事件
    handleClose (done) {
      done()
      // 清空记忆值
      this.getCompanyListParam.company_type = ''
      this.getCompanyListParam.company_name = ''
      this.getCompanyListParam.page = 1
    },
    // 公司列表筛选事件
    onCompanyList () {
      this.searchCompanyList()
    },
    // 权限清单分页功能
    handleSizeChangeTemp (current) {
      this.jobPermissionTempListParam.page_size = current
      this.getJobPermissionTempList()
    },
    //权限清单分页
    handleCurrentChangeTemp (current) {
      // console.log(current, 'current change')
      this.jobPermissionTempListParam.page = current
      this.getJobPermissionTempList()
    },
    // 权限清单分页功能
    handleSizeChange (current) {
      this.jobPermissionListParam.page_size = current
      this.getJobPermissionList()
    },
    //权限清单分页
    handleCurrentChange (current) {
      // console.log(current, 'current change')
      this.jobPermissionListParam.page = current
      this.getJobPermissionList()
    },
    // 人员列表清单分页功能
    handleJobUserCurrentChange (current) {
      this.getJobUserListParams.page = current
      this.getJobUserList()
    },
    handlePeopleSizeChange (page) {
      this.getJobUserListParams.page_size = page
      this.getJobUserList()
    },
    // 获取公司类型列表
    getCompanyTypeList () {
      OBSManageApi.getCompanyTypeList({
        params: {
          code_type: 'companyType',
          is_page: 0
        }
      }).then(res => {
        // console.log(res, 'get company type list')
        if (res.code === 0) {
          // console.log('csy-arr-companyTypeList=', this.companyTypeList, res.data.list)
          this.companyTypeList = res.data.list
          this.companyTypeList.unshift({ name: '全部', value: '' })
        }
      })
    },
    // 获取左侧组织树
    getOrgainzationTree () {
      this.companyListVisible = false
      this.companyName = this.orgainzationTreeParam.company_name
      OBSManageApi.getOrganizationTree({
        params: this.orgainzationTreeParam
      }).then(res => {
        if (res.code === 0) {
          let data = this.handelData(res.data)
          this.orgainzationTreeData = data
          this.$store.dispatch('setOrgainzationTree', this.orgainzationTreeData)
          window.localStorage.setItem('orgainzationTree', JSON.stringify(this.orgainzationTreeData))
        }
      })
    },
    // 处理传入的数据，手动赋值一个org_id，因为有些节点的id相同
    handelData (arr, parnetList = []) {
      if (Object.prototype.toString.call(arr) === '[object Array]') {
        arr.map((item) => {
          // 除顶级目录和项目级别目录，项目级以下的权限项都可以选择
          item.org_id = item.id + item.no
          let temp = JSON.parse(JSON.stringify(parnetList))
          temp.push(item.name)
          item.parentList = temp

          if (item.children_list) {
            this.handelData(item.children_list, temp)
          }
        })
        return arr
      }
    },
    // 获取岗位权限清单列表数据
    getJobPermissionList () {
      console.log(this.jobPermissionListParam.job_id);
      OBSManageApi.getJobList({
        params: this.jobPermissionListParam
      }).then(res => {
        // console.log(res, 'get jpb permission list')
        if (res.code === 0) {
          this.jobPermissionList = res.data
          if (this.jobPermissionList.list.length != 0 || this.jobPermissionList.list == undefined) {
            this.setCurrentNext(this.jobPermissionList[0])
          } else {

          }
        }
      })
    },
    //获取轻应用列表
    getLightappList () {
      OBSManageApi.getLightappList({
        params: this.getAppLimitParam
      }).then(res => {
        if (res.code === 0) {
          this.applimit = res.data
          if (this.applimit.list.length != 0 || this.applimit.list == undefined) {
            this.setCurrentNext(this.applimit[0])
          } else {

          }
        }
      })
    },
    //轻应用权限-移除按钮
    appLimitDeleteConfirm (row) {
      this.$confirm('是否删除该权限清单？', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        OBSManageApi.deleteAppList({
          data: {
            job_id: row.job_id,
            app_id: row.app_id
          }
        }).then(res => {
          if (res.code === 0) {
            this.$message.success('删除轻应用成功')
            this.getLightappList()
          }
        })
      })
    },
    // 删除权限模板-调用接口
    jobPerDeleteApiTemp (id) {
      OBSManageApi.deleteTempJobPermission({
        data: {
          role_job_rela_id: id
        }
      }).then(res => {
        if (res.code === 0) {
          this.$message.success('删除权限模板成功')
          this.handleCurrentChangeTemp(1);//刷新
        }
      })
    },
    // 删除权限清单确认弹框
    jobPerDeleteConfirmTemp (scope) {
      this.$confirm('是否删除该权限模板？', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.jobPerDeleteApiTemp(scope.row.role_job_rela_id)
      })
    },
    // 删除权限清单确认弹框
    jobPerDeleteConfirm (scope) {
      this.$confirm('是否删除该权限清单？', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.jobPerDeleteApi(scope.row.job_object_rela_id)
      })
    },
    // 删除权限-调用接口
    jobPerDeleteApi (id) {
      OBSManageApi.deleteJobPermission({
        data: {
          job_object_rela_id: id
        }
      }).then(res => {
        if (res.code === 0) {
          this.$message.success('删除权限清单成功')
          this.getJobPermissionList()
        }
      })
    },

    // 获取人员列表
    getJobUserList () {
      OBSManageApi.getJobUserList({
        params: this.getJobUserListParams
      }).then(res => {
        // console.log(res, 'get job user list')
        if (res.code === 0) {
          this.jobUserList = res.data
          if (this.jobUserList.list.length != 0 || this.jobUserList.list != undefined) {
            // 默认给表格数据的第一行添加背景色
            this.setCurrent(this.jobUserList.list[0])
          } else {

          }
        }
      })
    },
    // 人员列表-删除-弹框
    jobUserDeleteConfirm (scope) {
      this.$confirm('是否删除该人员？', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.jobUserDeleteApi(scope.row)
      })
    },
    // 人员列表-删除-调用api
    jobUserDeleteApi (row) {
      let obj = {}
      obj.node_type = this.getJobUserListParam.node_type
      if (this.getJobUserListParam.node_type === '3') {
        obj.job_user_id = row.job_user_id
      } else {
        obj.user_id = row.user_id
      }

      OBSManageApi.deleteJobUser({
        data: obj
      }).then(res => {
        // console.log(res, 'delete job user')
        if (res.code === 0) {
          this.$message.success('删除人员成功')
          this.getJobUserList()
        }
      })
    },
    // 获取分配人员列表
    getAssignUserList () {
      this.getAssignUserListParam.comp_id = this.orgainzationTreeParam.company_id
      // 这里清空assignNode是为了关闭弹框再次点击分配人员时能够触发watch
      // 因此在watch时需要判断assignNode是否为空，否则会无限循环
      this.assignNode = {}
      OBSManageApi.getAssignUserList({
        params: this.getAssignUserListParam
      }).then(res => {
        // console.log(res, 'get assign user list')
        if (res.code === 0) {
          this.assignUserList = res.data
        }
      })
    },
    // 保存分配人员
    batchAssignUser () {
      if (this.selectedAssignUser.length == 0) {
        this.$message('请先选中数据!')
      } else {
        let param = {}
        param.job_id = this.getAssignUserListParam.job_id
        param.user_ids = this.selectedAssignUser.join(',')
        OBSManageApi.batchAssignUser({
          data: param
        }).then(res => {
          // console.log(res, 'batch assign user')
          if (res.code === 0) {
            this.$message.success('分配人员成功')
            this.assignUserListVisible = false
          }
        })
      }
    },
    // 选择分配人员
    selectUser (list) {
      this.selectedAssignUser = []
      if (list.length > 0) {
        list.map((item) => {
          this.selectedAssignUser.push(item.user_id)
        })
      }
    },
    // 获取分配模板列表
    getAssignTemplate () {
      this.assignTemplateNode = {}
      this.getAssignTemplateListParam.company_id = this.orgainzationTreeParam.company_id
      // this.getAssignTemplateListParam.org_no = '001'
      OBSManageApi.getAssignTemplateList({
        params: this.getAssignTemplateListParam
      }).then(res => {
        // console.log(res, 'get assign template list')
        if (res.code === 0) {
          this.assignTemplateList = res.data
        }
      })
    },
    // 保存分配模板
    saveAssignTemplate () {
      if (this.selectedAssignTemplate.length == 0) {
        this.$message('请先勾选数据!')
      } else {
        let param = {}
        param.job_id = this.getAssignTemplateListParam.job_id
        param.auth_template_ids = this.selectedAssignTemplate.join(',')
        OBSManageApi.saveAssignTemplate({
          data: param
        }).then(res => {
          // console.log(res, 'save assign template')
          if (res.code === 0) {
            this.$message.success('分配模板成功')
            this.assignTemplateListVisible = false
            this.getJobPermissionTempList();//权限模版
            this.getJobPermissionList()
            this.getAssignTemplate()
          }
        })
      }
    },
    // 获取选中的模板
    selectTemplate (list) {
      this.selectedAssignTemplate = []
      if (list.length > 0) {
        list.map((item) => {
          this.selectedAssignTemplate.push(item.auth_template_id)
        })
      }
    },
    // 获取权限列表
    getPermissionList (scope) {
      this.permissionListVisible = true

      // this.dialogVisibleNum = true;
      this.getPermissionListParam.auth_template_id = scope.row.auth_template_id
      OBSManageApi.getTemplatePermissionList({
        params: this.getPermissionListParam
      }).then(res => {
        // console.log(res, 'get template permission list')
        if (res.code === 0) {
          this.permissionList = res.data
        }
      })
    },
    // 显示公司列表弹框
    showCompanyListDialog () {
      this.companyListVisible = true
      this.getCompanyList()
      this.orgainzationTreeParam.company_id = undefined
      this.orgainzationTreeParam.company_name = undefined
    },
    // 搜索公司列表
    searchCompanyList () {
      this.getCompanyListParam.page = 1
      this.getCompanyList()
    },
    // 获取公司列表
    getCompanyList () {
      OBSManageApi.getCompanyList({
        params: this.getCompanyListParam
      }).then(res => {
        // console.log(res, 'get company list')
        if (res.code === 0) {
          this.companyList = res.data
        }
      })
    },
    // 公司列表分页跳转
    handleCompanyCurrentChange (current) {
      this.getCompanyListParam.page = current
      this.getCompanyList()
    },
    // 公司列表选择行
    selectCompany (row) {
      this.orgainzationTreeParam.company_id = row.company_id
      this.orgainzationTreeParam.company_name = row.company_name
    },
    // 在下拉框中选择公司
    chooseCompany (item) {
      //切换的时候更新一下存储的单位
      window.sessionStorage.setItem('unitDefaultData', JSON.stringify(this.selectedCompany))
      this.orgainzationTreeParam.company_id = item.company_id
      this.orgainzationTreeParam.company_name = item.company_name
      this.getOrgainzationTree()
    },
    // 在弹框中确定选择某行数据
    confirmChooseCompany () {
      // console.log('csy====', this.orgainzationTreeParam.company_id, this.orgainzationTreeParam.company_name);
      if (this.orgainzationTreeParam.company_id == undefined && this.orgainzationTreeParam.company_name == undefined) {
        this.$message('请先选中数据!')
      } else {
        this.updateSelectedCompanyList(this.orgainzationTreeParam.company_id, this.orgainzationTreeParam.company_name)
        // console.log(this.selectedCompanyList, 'selected company list')
        this.getOrgainzationTree()
      }
    },
    // 如果已选择公司列表中不存在该公司，则添加该公司
    updateSelectedCompanyList (id, name) {
      let flag = false
      this.selectedCompanyList.map((item) => {
        if (item.company_id === id) { //重复选择时,表格中选中之后,外面的input的默认值也随之变化
          flag = true
          let obj = {
            company_id: id,
            company_name: name
          }
          this.selectedCompany = obj
          console.log(this.selectedCompany);
          window.sessionStorage.setItem('unitDefaultData', JSON.stringify(this.selectedCompany))
        }
      })
      if (!flag) {
        let obj = {
          company_id: id,
          company_name: name
        }
        this.selectedCompany = obj
        this.selectedCompanyList.push(obj)
        //将选择的单位存到sessonStorage里面,列表数据,和当前选择的值
        window.sessionStorage.setItem('unitData', JSON.stringify(this.selectedCompanyList))
        window.sessionStorage.setItem('unitDefaultData', JSON.stringify(this.selectedCompany))
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.head-left-selectunit {
  width: 50%;
  // margin: 0px;
  padding: 0px;
  text-align: center;
  height: 40px;
  line-height: 40px;
}
.head-left-btn {
  display: flex;
  justify-content: space-between;
  width: 50%;
}
.Permiss /deep/ .el-tabs__header {
  padding: 0;
  position: relative;
  margin: 0 0 15px;
  margin: 0px !important;
}
.obs-style {
  width: 100% !important;
}
/deep/ .obs-style .el-table__body tr.current-row > td {
  background: #1890ff;
  color: #fff;
}
/deep/ .obs-style .el-table__body tr.current-row > td .el-button {
  color: #fff;
}
/deep/ #pagination .el-pager .active {
  background: #1abc9c;
  color: white;
}
/deep/ #pagination .el-pager .active:hover {
  color: #fff;
}
/deep/ #pagination .el-pager li:hover {
  color: #1abc9c;
}
#back-style {
  color: white;
  background: rgba(26, 188, 156, 1);
}
#headLeftSelect {
  background: rgba(26, 188, 156, 1);
}
.show-dialog-style {
  margin-bottom: 20px;
}
/deep/ .show-table-style .current-row > td {
  background: #1890ff !important;
  color: white;
}
/deep/ .person-style .el-input-group__append {
  border-left: 0;
  background: #1abc9c !important;
  border: 3px solid #1abc9c !important;
  color: white;
  border-radius: 4px;
}
/deep/ .el-tabs__content {
  overflow: hidden;
  position: relative;
  padding: 0px 0px !important;
}
.select-company {
  display: flex;
}
/deep/ .select-company .el-select {
  display: inline-block;
  float: left;
  margin-right: 20px;
  width: 50%;
}
.el-pagination {
  text-align: center;
}
.OBSMaintain {
  background: #ffffff;
  height: 100%;
  min-height: 400px;
  // .company-list-container {
  //   background-color: #fff;
  //   width: 250px;
  //   padding: 10px;

  //   .select-company {
  //     display: flex;
  //     width: 230px;
  //     margin: 10px 0;
  //     .el-button {
  //       margin-left: 5px;
  //       height: 40px;
  //       line-height: 9px;
  //     }
  //   }
  //   .search-btn {
  //     margin-left: 15px;
  //   }
  // }
}
.row_maintain {
  padding: 20px;
  height: 100%;
  > .el-col {
    height: 100%;
    .left-content {
      height: 100%;
      display: flex;
      flex-direction: column;
    }
  }
}
.col_tabs {
  padding: 0 10px;
  padding-right: 0px !important;
  padding-left: 20px !important;
  height: 100%;
  .unit_tabs {
    height: 100%;
    display: flex;
    flex-direction: column;
    .el-tab-pane {
      height: 100%;
      .el-tabs {
        height: 100%;
      }
      .el-row {
        height: 100%;
        .table-container {
          height: 100%;
        }
        .table-content {
          height: 90%;
        }
        .obs-style {
          height: 100%;
        }
      }
    }
  }
}
.normal_btn {
  width: 100% !important;
  color: #fff;
  background: #1abc9c;
}
#obs_page {
  margin-top: 10px;
}
/deep/ #obs_page .el-pager .active {
  background: #1abc9c;
}
/deep/ #obs_page .el-pager .active:hover {
  color: #fff;
}
/deep/ #obs_page .el-pager li:hover {
  color: #1abc9c;
}
/deep/ .Permiss .el-tabs__header {
  margin-top: 0px !important;
  border-bottom: none !important;
}
/deep/ .Permiss .el-tabs--card > .el-tabs__header {
  border-bottom: none !important;
}
.tree-container {
  width: 100% !important;
  min-height: 300px;
  flex: 1;
}
/deep/ .unit_tabs .el-tabs__item {
  font-size: 15px;
}
</style>
